package thread.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockTest implements Runnable{
    public ReentrantLock lock = new ReentrantLock();
    public static void main(String [] args) throws InterruptedException {
        ReentrantLockTest reentrantLockTest1 = new ReentrantLockTest();
        ReentrantLockTest reentrantLockTest2 = new ReentrantLockTest();
        ReentrantLockTest reentrantLockTest3 = new ReentrantLockTest();
        Thread t1 = new Thread(reentrantLockTest1);
        Thread t2 = new Thread(reentrantLockTest2);
        Thread t3 = new Thread(reentrantLockTest3);
        t1.start();
        t2.start();
        t3.start();
        t1.join();
        t2.join();
        t3.join();
    }

    public void run() {
        lock.lock();
        System.out.println(Thread.currentThread().getName());
        lock.unlock();
    }
}
